{include file="public/header"/}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal" id="init_form">
                        <!--表单项-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">代码类型
                                {$html->tips('CRUD：增删改查  Table：表格')}
                            </label>
                            <div class="col-sm-10">
                                <div class="radio i-checks" id="codeType">
                                    <label><input type="radio" value="1" name="type" checked> CRUD</label>
                                    <label><input type="radio" value="2" name="type">  Table</label>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div id="searchDiv">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">模块
                                </label>
                                <div class="col-sm-10">
                                    <div class="checkbox i-checks checkbox-inline">
                                        <label><input type="checkbox" value="1" name="item[]" checked> Model</label>
                                    </div>
                                    <div class="checkbox i-checks checkbox-inline">
                                        <label><input type="checkbox" value="2" name="item[]" checked> Validate</label>
                                    </div>
                                    <div class="checkbox i-checks checkbox-inline">
                                        <label><input type="checkbox" value="3" name="item[]" checked> Controller</label>
                                    </div>
                                    <div class="checkbox i-checks checkbox-inline">
                                        <label><input type="checkbox" value="4" name="item[]" checked> Index</label>
                                    </div>
                                    <div class="checkbox i-checks checkbox-inline">
                                        <label><input type="checkbox" value="5" name="item[]" checked> Add</label>
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <div id="dbDiv" hidden>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">报表名称
                                </label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="viewName" value="" >
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">接口
                                </label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="url" value="" >
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                        <!--/表单项-->
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="create()">确定</button>
                                <button class="btn btn-white" type="button" onclick="layer_close();">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer"/}
<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">
    $(function () {
        $('#codeType').find("[type='radio']").on('ifChecked', function(event){
            var type=$(this).val();
            if(type==1){
                $("#searchDiv").show();
                $("#dbDiv").hide();
            }else{
                $("#searchDiv").hide();
                $("#dbDiv").show();
            }
        });
    });


    var chk_value=$('#checkItem', parent.document).val();
    function create() {
        $.ajax({
            url: "create?tables="+chk_value,
            type: 'POST',
            dataType: 'json',
            data:$("#init_form").serializeJSON(),
            success: function (res) {
                if (res.rc == 0) {
                    parent.toastr.success("创建成功！");
                    layer_close();
                } else {
                    layer.msg('创建失败！', {icon: 2});
                }
            }
        });
    }
</script>
